window.onload = function () {
  //左侧滑动
  //leftSwipe();
  iscrollLeft();
  //右侧滑动
  rightSwipe();
};
var leftSwipe = function () {
  /**
   * 1.上下的滑动 (touch事件，位移)
   *
   */
  var paerntBox = document.querySelector(".cate_left");
  var childBox = paerntBox.querySelector("ul");

  var startY = 0;
  var distanceY = 0;

  /*程序的核心的*/
  var currentY = 0;
  childBox.addEventListener("touchstart", function (e) {
    startY = e.touches[0].clientY;
  });
  childBox.addEventListener("touchstart", function (e) {
    var moveY = e.touches[0].clientY;
    distanceY = moveY - startY;
    /*将要去做定位的位置*/
    var translateY = currentY + distanceY;

    childBox.style.transform = "translateY(" + translateY + "px)";
  });
  childBox.addEventListener("touchstart", function (e) {
    //滑动完成之后记录位置
    currentY = currentY + distanceY;
  });
};

var iscrollLeft = function () {
  new IScroll(document.querySelector(".cate_left"));
};
var rightSwipe = function () {
  new IScroll(document.querySelector(".cate_right"), {
    scrollX: true,
    scrollY: false,
  });
};
